package com.zhanbo.zhanbowymusic.main.featured.adapter;

import android.content.Context;
import android.view.View;

import com.mwx.baselib.base.BaseBindingAdapter;
import com.mwx.baselib.bean.PlayListSongBean;
import com.mwx.baselib.bean.RanKingSongListBean;
import com.mwx.baselib.net.LikeMusic;
import com.mwx.baselib.utils.GlideUtils;
import com.zhanbo.zhanbowymusic.R;
import com.zhanbo.zhanbowymusic.databinding.ItemCreateListDetailsBinding;

public class RanKingDetailsListAdapter extends BaseBindingAdapter<RanKingSongListBean, ItemCreateListDetailsBinding> {
    private  int itemNumber=1;
    public RanKingDetailsListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_create_list_details;
    }

    @Override
    protected void onBindItem(ItemCreateListDetailsBinding binding, RanKingSongListBean item) {
        if (item.getSong().getIsLike()==0){
            binding.ivLike.setImageResource(R.mipmap.like_no);
        }else {
            binding.ivLike.setImageResource(R.mipmap.like);
        }
        binding.ivLike.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.getSong().setIsLike(item.getSong().getIsLike()==1?0:1);
                LikeMusic.like(context,item.getId()+"");
                notifyDataSetChanged();
            }
        });
        binding.likeListItemNum.setText((itemNumber++)+"");
        GlideUtils.loadImageRounded10(context,item.getSong().getCoverImg(),binding.likeListItemIcon);
        binding.likeListItemSong.setText(item.getSong().getName()+"");
        binding.albumName.setText(item.getSong().getAlbumName()+"");
        binding.tvArtistAme.setText(item.getSong().getArtistName()+"");
        binding.tvDuration.setText(String.valueOf(item.getSong().getDuration()+"").replace(".",":"));

    }
}
